clear

*import excel "C:\Users\abrah\Dropbox\Paper AA-GM\Analysis for new experiment\Study2.xlsx", sheet("Sheet0") firstrow
import excel "/Users/gwynethmcclendon/Dropbox/Paper AA-GM/Replication materials Overtly Religious Appeals JOP/Study2.xls", sheet("Sheet0") firstrow

destring, replace



*************************
**Treatments**

*Generate numeric message treatments and dummies for each
encode message, gen(message_treat)
gen message_multi=0
recode message_multi (0=1) if message_treat==1

gen message_overt=0
recode message_overt (0=1) if message_treat==2


gen message_sec=0
recode message_sec (0=1) if message_treat==3

gen message_rel=0
replace message_rel=1 if message_treat==1 | message_treat==2

**Outcome variables**

*Generate Support for candidate 
gen candsupport=support
replace candsupport= AX if candsupport==.
replace candsupport= BD if candsupport==.

*Generate candidate qualified
gen candqualified= qualified
replace candqualified= AY if candqualified==.
replace candqualified= BE if candqualified==.

*Generate candidate represents
gen candrepresent=represent
replace candrepresent=AZ if candrepresent==.
replace candrepresent=BF if candrepresent==.

*Generate candidate religious
gen candreligious=religious
replace candreligious= BA if candreligious==.
replace candreligious=BG if candreligious==.

*Generate candidate eloquent
gen candeloquent= eloquent
replace candeloquent= BB if candeloquent==.
replace candeloquent= BH if candeloquent==.


*Generate candidate thoughtful
gen candthoughtful=thoughtful
replace candthoughtful=BC if candthoughtful==.
replace candthoughtful=BI if candthoughtful==.

**measure of compliance with dangers treatment***
sum highquality if dangers==1

**************************
**Demographic Covariates**
**************************

*Rename Religious
rename Religious responrelig

*Generate Christian Nationalism scale (Note that cnat_5 is not included because it was an attention check and that cnat_3 is reverse coded)
gen cnat= cnat_1+ cnat_2+6- cnat_3+ cnat_4+ cnat_6+ cnat_7
sum cnat
sum cnat, d
gen high_cnat=0
replace high_cnat=1 if cnat>18 & cnat~=.
replace high_cnat=. if cnat==.
tab responrelig high_cnat


*Generate party numeric (note that this includes leaners)
encode Party, gen(party_num)
gen democrat=0
replace democrat=1 if party_num==1
gen republican=0 
replace republican=1 if party_num==2

tab responrelig republican, row

*For pure partisans use these variable
gen democratpid=1 if pid1==1
recode democratpid (.=0)

gen republicanpid=1 if pid1==2
recode republicanpid (.=0)

gen independentpid=1 if pid1==3
recode independentpid (.=0)


recode pid1 (1=1) (2=3) (3=2), gen(pid_reordered)
label define pidlabel 1 "Democrat" 2 "Independent" 3 "Republican" 
label values pid_reordered pidlabel

**Other demographics**

*Race
split race, p(",")
destring race1 race2 race3 race4, replace

gen asian=1 if race1==1 
recode asian (.=0)
gen black=1 if race1==2 
recode black (.=0)
gen nativeamerican=1 if race1==3 
recode nativeamerican (.=0)
gen white=1 if race1==4 
recode white (.=0)
gen other=1 if race1==5 
recode other (.=0)
gen mixedrace=1 if race2!=.
recode mixedrace (.=0)

ttest cnat, by(white) unequal


recode latino (2=0)

ttest cnat, by(latino) unequal


*Gender
recode gender (1=0) (2=1) (3 4=.), gen(female)

*Education
gen college=0 if educ==1 | educ==2 | educ==3 | educ==4
replace college=1 if educ==5 | educ==6 |educ==7

*Political participation
gen evervoted=0
replace evervoted=1 if voted_ever==1

recode voted_2020 (2=0)

recode voted_2020 (.=0) if evervoted==0

recode workpols (2=0)



*Religiosity
recode oftenservices (1=5) (2=4) (3=3) (5=1) (4=2), gen(oftenservices_reordered)
label define oftenserviceslabel 1 "Never" 2 "A Few Times a Year" 3 "Once or Twice a Month" 4 "Almost Every Week" 5 "Every week"
label values oftenservices_reordered oftenserviceslabel

gen veryreligious=0
replace veryreligious=1 if oftenservices_reordered==4 | oftenservices_reordered==5

gen mostreligious=0
replace mostreligious=1 if oftenservices_reordered==5

gen childrelig=.
replace childrelig=1 if often12==1 | often12==2 | often12==3
replace childrelig=0 if often12==4 | often12==5 

gen believeingod=.
replace believeingod=1 if deitybelief==1 | deitybelief==2 | deitybelief==3
replace believeingod=0 if deitybelief==4 | deitybelief==5 | deitybelief==6 | deitybelief==7

recode deitybelief (1 2 3 4 =1) (5 6 7=0), gen(spiritual)

recode deitybelief (1=1) (2 3 4 5 6 7 =0), gen(beliefgodnodoubts)

gen mostfervent=0
replace mostfervent=1 if beliefgodnodoubts==1 & oftenservices==1

ttest believeingod, by(democrat) unequal
ttest responrelig, by(democrat) unequal
ttest spiritual, by(democrat) unequal

gen somehoursreligious=.
replace somehoursreligious=1 if timereligious>1 & timereligious~=.
replace somehoursreligious=0 if timereligious==1 

gen timereligious_rev=.
replace timereligious_rev=timereligious if timereligious>1 & timereligious~=.
replace timereligious_rev=0 if timereligious==1 

tab spiritual responrelig 

recode region (2 3 4=0), gen(northeast)
recode region (2=1) (1 3 4=0), gen(midwest)
recode region (3=1) (1 2 4=0), gen(south)
recode region (4=1) (1 2 3=0), gen(west)
label variable south South


tab religion, gen(denom)
rename denom1 catholic
rename denom2 mainline
rename denom3 evangelical
rename denom4 otherchristian
rename denom5 agnostic
rename denom6 atheist
rename denom7 none
rename denom8 secular
rename denom9 humanist 

gen notrelig=agnostic+atheist+none+secular+humanist

gen christian=-1*(notrelig-1)

gen secularism_index=-1*(personalsecularism_1+personalsecularism_2+personalsecularism_3+personalsecularism_4)+24

sum secularism_index, d

tab believeingod responrelig, row

gen religious_rev=.
replace religious_rev=1 if secularism_index<14
replace religious_rev=0 if (secularism_index>14 & secularism_index~=.) | (secularism_index==14) /*need to reverse scoring because 1 was more in agreement with secular statements in original survey*/

gen religiousnotsecular=.
replace religiousnotsecular=1 if religious_rev==1 & responrelig==1
replace religiousnotsecular=0 if religious_rev==0 | responrelig==0

gen religiousnat=.
replace religiousnat=1 if high_cnat==1 & responrelig==1
replace religiousnat=0 if high_cnat==0 | responrelig==0

gen notsecularnat=.
replace notsecularnat=1 if high_cnat==1 & religious_rev==1
replace notsecularnat=0 if high_cnat==0 | religious_rev==0

*Attention check question
gen inattentive=1
replace inattentive=0 if cnat_5==5 
replace inattentive=. if cnat_5==.
/*13.8% inattentive*/

************************************
***Figure 8a************************
************************************

*****Figure 8a: Support for the Candidate, Evaluation Task -- no dangers, CHRISTIAN NATIONALISM**
recode message_treat (1=2) (2=1) (3=3), gen(message_reordered)
collapse (mean) meancandsupport=candsupport (semean) secandsupport=candsupport if dangers==0, by(message_reordered high_cnat)
gen hisupport=meancandsupport+1.96*secandsupport
gen lowsupport=meancandsupport-1.96*secandsupport
label define responreliglabel 0 "Low Christian Nationalism" 1 "High Christian Nationalism"
label values high_cnat responreliglabel

twoway (bar meancandsupport message_reordered if message_reordered==2, fcolor(white) lcolor(black))(bar meancandsupport message_reordered if message_reordered==1, fcolor(gray) lcolor(black)) (bar meancandsupport message_reordered if message_reordered==3, fcolor(darkgray) lcolor(black))  (rcap hisupport lowsupport message_reordered, lcolor(black)), xscale(off) xlabel(1   "Overtly Religious" 2   "Multi-Vocal"  3 "Secular", labels labsize(small)) by(, legend(off)) by(, graphregion(fcolor(white)) plotregion(fcolor(white))) by(high_cnat, note("")) subtitle( , fcolor(white) lcolor(white))  ytitle("Support for the Candidate (5=Full Support)") ysc(r(0 5)) ytick(0 (1) 5, labels) xtitle("") 
